package com.ele.Servlet;

import com.ele.Pojo.Business;
import com.ele.Pojo.PageResult;
import com.ele.Service.impl.BusinessServiceImpl;
import com.google.gson.Gson;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/businessList")
public class BusinessListServlet extends HttpServlet {
    //
   BusinessServiceImpl businessService = new BusinessServiceImpl();

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String account = req.getParameter("account");
        String contact = req.getParameter("contact");
        String telephone = req.getParameter("telephone");
        String currentPage = req.getParameter("currentPage");
        String pageSize = req.getParameter("pageSize");
        PageResult<List<Business>> list = this.businessService.findAll(account,contact,telephone,currentPage,pageSize);
        String json = new Gson().toJson(list);
        resp.setContentType("application/json;charset=utf-8");
        resp.getWriter().write(json);
    }
}
